package com.twu.biblioteca;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * Created by lauraionescu on 21/04/2014.
 */
public class Movie extends Item{

    private String title;
    private int year;
    private String director;
    private double rating;

    public Movie(String title, int year, String director) {
        this.title = title;
        this.year = year;
        this.director = director;
    }

    public String toString(){
        return "\"" + title + "\"" +", " + year + ", " + director + ", " + rating;
    }

    public boolean equals(Object toBeChecked) {
        if (toBeChecked instanceof Movie)
            return ((Movie) toBeChecked).getTitle().equals(title) && ((Movie) toBeChecked).getYear() == year && ((Movie) toBeChecked).getDirector().equals(director);
        else
            return false;
    }

    public String getDirector() {
        return director;
    }

    public int getYear() {
        return year;
    }

    public String getTitle() {
        return title;
    }

    public double getRating() {
        return rating;
    }

    public void rate(double rating){
        this.rating = rating;
    }

    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

}
